<include file="Jinhuo:leftmenu" />
<style>
#uploadPic {
	padding:0px 0px 20px 0px;
	height:auto;
}
#uploadPic ul {
	list-style-type:none;
	margin:0px;
	padding:0px;
	border:0;
	float:left;
}
#uploadPic li {
	float:left;
	width:82px;
	height:88px;
	margin:0 5px 5px 0;
	padding-bottom:3px;
	overflow:hidden;
	background:#eee;
	position:relative
}
#uploadPic .displayimg {
	width:76px;
	height:60px;
	border:1px solid #ccc;
	overflow:hidden;
	background:#fff;
	padding:2px;
	text-align:center;
	vertical-align:middle;
}
#uploadPic .displayimg img {
	width:76px;
	height:60px;
}
#uploadPic .previous {
	display:inline-block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -7px;
	line-height:100px;
	vertical-align:middle;
	overflow:hidden;
	margin:-12px 33px 0 12px;
	margin:7px 33px 0 12px\9;
*margin:7px 33px 0 12px;
	_margin:7px 33px 0 12px;
}
#uploadPic .previous:hover {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -19px;
}
#uploadPic .previous:active {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -7px;
}
#uploadPic .next {
	display:inline-block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -7px;
	line-height:100px;
	vertical-align:middle;
	overflow:hidden;
	margin:-12px 0 0;
	margin:7px 0 0\9;
*margin:7px 0 0;
	_margin:7px 0 0;
}
#uploadPic .next:hover {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -19px;
}
#uploadPic .next:active {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -7px;
}
#uploadPic .delete {
	display:block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/closeyes.gif) no-repeat 0 0;
	line-height:100px;
	overflow:hidden;
	position:absolute;
	top:3px;
	right:3px;
	z-index:999
}
#uploadPic .delete:hover {
	background:url(/Static/admin/js/swfupload/img/close-hover.gif) no-repeat 0 0;
}
#uploadPic .front-cover {
	position:absolute;
	bottom:5px;
    *bottom:-8px;
	left:30px;
	color:#666
}
#uploadPic div {
	clear:both;
}
#uploadPic input.picDesc {
	width:80px;
*width:78px;
	text-align:center;
	margin:0;
	border:1px solid #7F9DB9;
	margin-top:2px;
	display:none;
}
#uploadPic span.upload_error {
	background-color:#FFD7D7;
	color:#000;
	padding:4px;
	font-family:Tahoma;
	line-height:24px;
}
#upload_tip {
	padding-left:15px;
	height:27px;
	line-height:27px;
}
#upload_tip span {
	color:#F30
}
.purviews {
	padding:10px 300px 10px 10px;
}
.purviews p{
	line-height:18px;
}
.purviews span {
	font-variant:normal;
	display:block;
	float:left;
	width:12%;
}
.jindubox {
	width:500px;
	margin:0 auto;
	height:30px;
	background: #CCC;
}
.jindu {
	color:#FFF;
	font-size:12px;
	font-weight:bolder;
	background:url(/Static/admin/js/swfupload/img/bfbg.gif) left top repeat-x;
	height:30px;
}
</style>
<script type="text/javascript" src="__STATIC__admin/js/swfupload/swfupload.js" ></script>
<script type="text/javascript" src="__STATIC__admin/js/swfupload/multiupload.js" ></script>

<div class="content-right fl">
    <h1 class="content-right-title">我要进货</h1>
    

<form id="form" aciton="" method="post" id="add" onsubmit="return false">

  
<div class="panel-single panel-single-light mgt20">
    <h3 class="cst_h3 mgb20">收货人信息</h3>
    <div class="formitems">
        <label class="fi-name">手机号：</label>
        <div class="form-controls">
            <input type="text" class="input " name="delivery_mobile" value="" >
            <span class="fi-help-text">请输入收货人手机号</span>
        </div>
    </div>
    
	<div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>省份：</label>
        <div class="form-controls">
            <input type="text" class="input" name="province" value="">
            <span class="fi-help-text">请输入收货人省份</span>
        </div>
    </div>
    
	<div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>城市：</label>
        <div class="form-controls">
            <input type="text" class="input" name="city" value="">
            <span class="fi-help-text">请输入收货人城市</span>
        </div>
    </div>
    
    
	<div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>城市：</label>
        <div class="form-controls">
            <input type="text" class="input" name="county" value="">
            <span class="fi-help-text">请输入收货人区/县</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">市场专柜价：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="market_price" value="<?php echo $goods['market_price'];?>">
            <span>元</span>
            <span class="fi-help-text">市场售价,供参考</span>
        </div>
    </div>

    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>普通会员价：</label>
        <div class="form-controls">
            <input type="text" class="input mini" id="shop_price" name="shop_price" value="<?php echo $goods['shop_price'];?>">
            <span>元</span>
            <span class="fi-help-text">网上商城售价</span>
        </div>
    </div>
    
     <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>CEO销售价：</label>
        <div class="form-controls">
            <input type="text" class="input mini" id="ceo_price" name="ceo_price" value="<?php echo $goods['ceo_price'];?>">
            <span>元</span>
        </div>
    </div>
    
     <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>皇冠销售价：</label>
        <div class="form-controls">
            <input type="text" class="input mini" id="king_price" name="king_price" value="<?php echo $goods['king_price'];?>">
            <span>元</span>
        </div>
    </div>
    

    
     <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>商品重量：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="goods_weight" value="<?php echo $goods['goods_weight'];?>">
            <span>千克</span>
            <span class="fi-help-text">商品重量</span>
        </div>
    </div>
    
	
	
	<!-- 
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>代理商售价：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="price_grade2" value="<?php echo $goods['price_grade2'];?>">
            <span>元</span>
            <span class="fi-help-text">代理商可以以此价格买入商品</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>股东销售价：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="price_grade3" value="<?php echo $goods['price_grade3'];?>">
            <span>元</span>
            <span class="fi-help-text">股东可以以此价格买入商品</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>董事销售价：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="price_grade4" value="<?php echo $goods['price_grade4'];?>">
            <span>元</span>
            <span class="fi-help-text">董事可以以此价格买入商品</span>
        </div>
    </div>
	
	-->

    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>总库存：</label>
        <div class="form-controls">
            <input type="text" class="input mini" id="j-totalStock" name="stock" value="<?php echo $goods['stock'];?>">
            <span><input type="text" class="input xmini" name="unit" value="<?php echo $goods['unit'];?>"></span>
            <span class="fi-help-text">请填写库存和单位</span>
        </div>
    </div>
    
    <div class="formitems" style="display:none">
        <label class="fi-name">规格：</label>
        <div class="form-controls">
        	
        	<?php for($i=0;$i<32;$i++){ ?>
            <span><input type="text" class="input mini" name="guige[]" value="<?php echo $goods['guige'][$i]['guige_size'];?>"></span>
            <?php } ?>
            
            <span class="fi-help-text">请选填商品规格: 例如: 大号  小号  中号   或  iphone5  iphone6  iphone6s</span>
        </div>
    </div>
    

	
	<div class="form-controls">
	<a class="fi-help-text btn btn-primary" id="add-guige" >添加规格</a>
	</div>
    
    <div class="formitems">
        <label class="fi-name">最小购买量：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="min_buy" value="<?php echo $goods['min_buy'] ? $goods['min_buy'] : 1;?>">
            <span class="fi-help-text">默认为1</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">最大购买数：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="max_buy" value="<?php echo $goods['max_buy'] ? $goods['max_buy'] : 999999999;?>">
            <span class="fi-help-text">最大购买数,默认不限制</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">成倍购买：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="double_buy" value="<?php echo $goods['double_buy'] ? $goods['double_buy'] : 1;?>">
            <span class="fi-help-text">必须以此数的倍数购买,默认为1</span>
        </div>
    </div>
    
    
    
    <div class="formitems">
        <label class="fi-name">排序：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="ord" value="<?php echo $goods['ord'];?>">
            <span class="fi-help-text">数字越小越靠前,越大越靠后</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否上架：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="ischeck" <?php echo isset($goods['ischeck']) && ($goods['ischeck']) ? "checked" : (!isset($goods['ischeck']) ? "checked":"");?>>上架</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="ischeck" <?php echo isset($goods['ischeck']) && (!$goods['ischeck']) ? "checked" : "";?>>放入仓库</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
	
	<div class="formitems" >
        <label class="fi-name">重消/品牌：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_brand" value="0" name="is_brand" <?php echo !$goods['is_brand']? "checked" : "";?>>重消</label>
                <label><input type="radio" class="is_brand" value="1" name="is_brand" <?php echo $goods['is_brand']? "checked" : "";?>>品牌</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>
    
    <div class="formitems" style="display:none;">
        <label class="fi-name">是否特价：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_tejia" value="1" name="is_tejia" <?php echo isset($goods['is_tejia']) && ($goods['is_tejia']) ? "checked" : "";?>>特价</label>
                <label><input type="radio" class="is_tejia" value="0" name="is_tejia" <?php echo isset($goods['is_tejia']) && (!$goods['is_tejia']) ? "checked" : (!isset($goods['is_tejia']) ? "checked":"");?>>非特价</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>
    
    <div class="formitems"  style="display:none;">
        <label class="fi-name">是否折扣：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_zhekou" value="1" name="is_zhekou" <?php echo isset($goods['is_zhekou']) && ($goods['is_zhekou']) ? "checked" : "";?>>折扣</label>
                <label><input type="radio" class="is_zhekou" value="0" name="is_zhekou" <?php echo isset($goods['is_zhekou']) && (!$goods['is_zhekou']) ? "checked" : (!isset($goods['is_zhekou']) ? "checked":"");?>>非折扣</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>

    
    
    <div class="formitems">
        <label class="fi-name">是否新品：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_new" value="1" name="is_new" <?php echo isset($goods['is_new']) && ($goods['is_new']) ? "checked" : "";?>>新品</label>
                <label><input type="radio" class="is_new" value="0" name="is_new" <?php echo isset($goods['is_new']) && (!$goods['is_new']) ? "checked" : (!isset($goods['is_new']) ? "checked":"");?>>非新品</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否热卖：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_hot" value="1" name="is_hot" <?php echo isset($goods['is_hot']) && ($goods['is_hot']) ? "checked" : "";?>>热卖</label>
                <label><input type="radio" class="is_hot" value="0" name="is_hot" <?php echo isset($goods['is_hot']) && (!$goods['is_hot']) ? "checked" : (!isset($goods['is_hot']) ? "checked":"");?>>非热卖</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否显示购物车：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_cart" <?php echo isset($goods['is_cart']) && ($goods['is_cart']) ? "checked" : (!isset($goods['is_cart']) ? "checked":"");?>>显示</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_cart" <?php echo isset($goods['is_cart']) && (!$goods['is_cart']) ? "checked" : "";?>>不显示</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否显示点赞框：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_vote" <?php echo isset($goods['is_vote']) && ($goods['is_vote']) ? "checked" : (!isset($goods['is_vote']) ? "checked":"");?>>显示</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_vote" <?php echo isset($goods['is_vote']) && (!$goods['is_vote']) ? "checked" : "";?>>不显示</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    
    <div class="formitems">
        <label class="fi-name">是否显示悬浮按钮：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_xuanfu" <?php echo isset($goods['is_xuanfu']) && ($goods['is_xuanfu']) ? "checked" : (!isset($goods['is_xuanfu']) ? "checked":"");?>>显示</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_xuanfu" <?php echo isset($goods['is_xuanfu']) && (!$goods['is_xuanfu']) ? "checked" : "";?>>不显示</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    
      <div class="formitems">
        <label class="fi-name">无购物车时购买按钮文字：</label>
        <div class="form-controls">
            <input type="text" class="input xlarge" name="buy_text" value="<?php echo $goods['buy_text'];?>">
            <span class="fi-help-text"></span>
        </div>
    </div>  
    
    

    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>商品主图：</label>
	    <div class="form-controls pdt5 j-imglistPanel">

    <div id="uploadPic">
      <ul id="uploadlist" style=" height:90px; overflow:hidden;">
		<?php $sx=0;$p = json_decode($goods['goods_thumb'],true);foreach($p as $k=>$v){?>
	        <li>
	          <div class="displayimg"><img src="<?php echo C("UPYUN_DOMAIN").$v;?>" /></div>
	          <a class="previous" href="javascript:void(0);"></a>
	          <span class="front-cover"><?php echo $sx==0 ? "封面":"";$sx++;?></span>
	          <a class="next" href="javascript:void(0);"></a>
	          <a class="delete" href="javascript:void(0);"></a>
	          <input type="hidden" name="goods_thumb[]" id="goods_thumb" value="<?php echo $v;?>" class="goods_thumb" />
	        </li>
		<?php } ?>
      </ul>
      <div style="clear:both;"></div>
    </div>
	    <span class="btn btn-primary j-add"><span id="upload"></span></span>
	        <span class="fi-help-text">可以一次性选择多张图片上传,最对可以上传5张图片<br>建议图片尺寸为640px * 640px<br>注意:商品主图不同于商品详情图</span>
	    </div>
    </div>
    


</div>


<div class="panel-single panel-single-light mgt20">
    <h3 class="cst_h3 mgb20">佣金设置</h3>
    
    <div class="formitems">
        <label class="fi-name" style="width:160px;">商品PV：</label>
        <div class="form-controls">
            <input type="text" class="input mini" id="brokerage_money" name="brokerage_money" value="<?php echo $goods['brokerage_money'];?>">
            <span></span>
        </div>
         <span class="fi-help-text">总分佣金额,举例说明:100的商品,拿出80元来分,即为80</span>
    </div>
    
    
    <div class="formitems">
        <label class="fi-name" style="width:160px;">总分佣占商品金额的比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini readonly" id="brokerage_percent" name="brokerage_percent" value="<?php echo $goods['brokerage_percent']*100;?>" readonly>
            <span>%</span>
        </div>
         <span class="fi-help-text">总分佣占商品金额的比率(PV),举例说明:100的商品,拿出80元来分,即为80%</span>
    </div>
    
    
    <div class="formitems" >
        <label class="fi-name" style="width:160px;">直属上级能拿到的佣金比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="directly_rate" value="<?php echo $goods['directly_rate']*100;?>">
            <span>%</span>
        </div>
        <span class="fi-help-text">说明:用户最终分得的金额为 PV乘以此比率</span>
    </div>

    <div class="formitems" >
        <label class="fi-name" style="width:160px;">二级上级能拿到的佣金比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="superior_rate" value="<?php echo $goods['superior_rate']*100;?>">
            <span>%</span>
        </div>
        <span class="fi-help-text">说明:用户最终分得的金额为 PV乘以此比率</span>
    </div>

    <div class="formitems" >
        <label class="fi-name" style="width:160px;">三级上级能拿到的佣金比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="three_rate" value="<?php echo $goods['three_rate']*100;?>">
            <span>%</span>
          
        </div>
        <span class="fi-help-text">说明:用户最终分得的金额为 PV乘以此比率</span>
    </div>
    
    <div class="formitems" style="display:none;">
        <label class="fi-name" style="width:160px;">四级上级能拿到的佣金比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="four_rate" value="<?php echo $goods['three_rate']*100;?>">
            <span>%</span>
          
        </div>
        <span class="fi-help-text">说明:用户最终分得的金额为 PV乘以此比率</span>
    </div>
    
    <div class="formitems" style="display:none;">
        <label class="fi-name" style="width:160px;">五级上级能拿到的佣金比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="five_rate" value="<?php echo $goods['three_rate']*100;?>">
            <span>%</span>
          
        </div>
        <span class="fi-help-text">说明:用户最终分得的金额为 PV乘以此比率</span>
    </div>
    
    <div class="formitems" style="display:none;">
        <label class="fi-name" style="width:160px;">六级上级能拿到的佣金比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="six_rate" value="<?php echo $goods['three_rate']*100;?>">
            <span>%</span>
          
        </div>
        <span class="fi-help-text">说明:用户最终分得的金额为 PV乘以此比率</span>
    </div>
    

    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>分销商返佣：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" value="1" name="is_fx_commission" <?php echo $goods['is_fx_commission'] ? "checked":"";?> >开启</label>
                <label><input type="radio" value="0" name="is_fx_commission" <?php echo $goods['is_fx_commission'] ? "":"checked";?>>关闭</label>
            </div>
            <span class="fi-help-text">关闭后，将不给分销商返佣。仅限重消商品</span>
        </div>
    </div>

    </div>


<div class="panel-single panel-single-light mgt20 j-showinhyd">
    <h3 class="cst_h3 mgb20">物流设置</h3>
    
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>需要物流：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_shiwu" <?php echo $goods['is_shiwu'] ? "checked" : "";?> >需要</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_shiwu" <?php echo $goods['is_shiwu'] ? "" : "checked";?> >不需要</label>
            </div>
            <span class="fi-help-text">会员购买免物流商品时，不需要填写收货地址。</span>
        </div>
    </div>
    
    <div class="formitems show" >
        <label class="fi-name"><span class="colorRed">*</span>运费设置：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="j-feight" value="1" name="freight_payer" <?php echo $goods['freight_payer']==1 ? "checked" : "";?>>包邮</label>
                <label><input type="radio" class="j-feight" value="2" name="freight_payer" <?php echo $goods['freight_payer']==2 ? "checked" : "";?>>统一运费</label>
            </div>
                  <input style="display:none" type="text" class="input xmini j-feight-ipt" name="shipping" value="<?php echo $goods['shipping'];?>">         
                     <span style="display:none" style="margin-right: 20px;">元</span>
            
        </div>
    </div>

</div>
<!-- end 物流及其它 -->

<div class="panel-single panel-single-light mgt20 txtCenter">

	<?php if($action=="add"){?>
	
	
	
	<?php }else{?>
	
	<a href="javascript:weSubmit(1);" class="btn btn-primary j-add">保存</a>
	
	<?php }?>



    <a href="javascript:weSubmit(2);" class="btn btn-primary j-add">保存并进入下 一 步</a>
</div>
</form>

</div>
<script type="text/javascript">
$(window).load(pageInit);
function pageInit(){
	
  var ext = '图片(*.gif;*.jpg;*.png;*.jpeg)';//默认值
  ext = ext.match(/([^\(]+?)\s*\(\s*([^\)]+?)\s*\)/i);
  
  swfu = new SWFUpload({
    flash_url : "/Static/admin/js/swfupload/swfupload.swf",
    prevent_swf_caching : false,//是否缓存SWF文件
    upload_url: '/admin/goods/uploadpic', //上传文件路径
    file_post_name : "imgFile",
    post_params:  {'mychatpath':'goods','imgcut':'1'},//随文件上传一同向上传接收程序提交的Post数据
    use_query_string : false,//是否用GET方式发送参数
    file_types : ext[2],//文件格式限制
    file_types_description : ext[1],//文件格式描述
    file_size_limit : '1MB',	//文件大小限制
    file_queue_limit:0,//上传队列总数
    file_upload_limit:5,//最多5张
    custom_settings : {
      test : "aaa"
    },
    file_queued_handler : fileQueued,//添加成功
    file_queue_error_handler : fileQueueError,//添加失败
    file_dialog_complete_handler : fileDialogComplete,
    upload_start_handler : uploadStart,//上传开始
    upload_progress_handler : uploadProgress,//上传进度
    upload_error_handler : uploadError,//上传失败
    upload_success_handler : uploadSuccess,//上传成功
    upload_complete_handler : uploadComplete,//上传结束
    button_placeholder_id : "upload",
    button_width: 80,
    button_height: 50,
    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
    button_cursor: SWFUpload.CURSOR.HAND,
    button_text : '<span class="redText">点击上传</span>',
    button_text_style: ".redText {color:#ffffff;}",
    button_text_left_padding: 10,
    button_text_top_padding: 5,
    debug: false
  });
}
</script>
<script>
function weSubmit(go){

	$.ajax({
		url : '/admin/goods/addGoods?goods_id=<?php echo get("goods_id");?>',
		type : "POST",
		data : $('#form').serialize(),
		dataType : 'json',
		async : false,
		success : function(data) {
			layer.closeAll('loading');//关闭正在加载
			if(data.ret == 0){
				// 成功
				var messagetype = 1;
			}else{
				// 失败
				var messagetype = 2;
			}
			if (data.url) {
				// 如果有跳转地址
				layer.msg(data.msg,{icon: messagetype}, function(){
					if(go==1){
						//不跳转
					}else{
						window.location.href = data.url;//跳转
					}
				}); 
				
			} else {
				layer.msg(data.msg, {icon: messagetype});
			}
		},
		beforeSend:function(){
			layer.load();//正在加载
       },
       error: function() {
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
}



//运费
$(".j-feight").change(function() {
	var a = $(".j-feight-ipt"),
		b = $("#freight_tpl_id");
	switch ($(this).val()) {
	case "1":
		a.attr("disabled", !0), b.attr("disabled", !0);
		break;
	case "2":
		a.attr("disabled", !1), b.attr("disabled", !0);
		break;
	case "3":
		a.attr("disabled", !0), b.attr("disabled", !1)
	}
});

//商品pv
$("#brokerage_money").change(function() {
	var brokerage_money = $("#brokerage_money").val();
	var shop_price = $("#shop_price").val();
	brokerage_percent = brokerage_money/shop_price*100;
	
	
	$("#brokerage_percent").val(brokerage_percent);

});

$('#add-guige').on('click',function(){
	var count = $('#guige-group').children('.formitems').length;
	if(count>=2){
		layer.msg('最多只能添加两个规格哦', {icon: 7});
		return false;
		}
	var item = '<div class="formitems" style="position:relative">'+
					'<button class="btn btn-danger guige-delete" style="position:absolute;right:20px">删除</button>'+
					'<label class="fi-name">规格：</label>'+
					'<div class="form-controls">'+
						'<input type="text" class="input mini" name="guige_names[]"><br>';
	for(var i=0;i<16;i++){
		item += '<span><input type="text" class="input mini" name="xx['+(count)+'][]" ></span>';
	}
	item += '<span class="fi-help-text">请选填商品规格: 例如: 大号  小号  中号   或  iphone5  iphone6  iphone6s</span>'+
			'</div>'+
			'</div>';
			
	$('#guige-group').append(item);
})

$('#guige-group').on('click','.guige-delete',function(){
    var title = "确定要删除该规格所有内容吗？";
	var self = $(this);
	layer.confirm(title, {
	    btn: ['确定','取消'] //按钮
	}, function(){
		
		var par = self.parents(".formitems");
		par.remove();
		
		//重新排序
		var childs = $('#guige-group').children('.formitems');
		$.each(childs,function(index,item){
			$(item).find("span > input").attr('name',"xx["+index+"][]");
		});
		
		$(".layui-layer").remove();
		$(".layui-layer-shade").remove();
		
	}, function(){
		layer.msg('你取消了删除操作', {icon: 7});
	});
	
	
	
	
});
</script>